package com.bwie.student.controller;

import com.bwie.common.domain.Clazz;
import com.bwie.common.domain.Student;
import com.bwie.common.domain.request.StudentRequest;
import com.bwie.common.result.PageResult;
import com.bwie.common.result.Result;
import com.bwie.student.service.StudentService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;


/**
 * @Author：ShenJiaFeng
 * @Package：com.bwie.student.controller
 * @Project：zg5_19
 * @name：StudentController
 * @Date：2024/2/17 8:57
 */
@RestController
@RequestMapping("/student")
public class StudentController {
    private final StudentService studentService;

    public StudentController(StudentService studentService) {
        this.studentService = studentService;
    }

    @PostMapping("/list")
    public Result<PageResult<Student>> studentList(@RequestBody StudentRequest studentRequest){
        Result<PageResult<Student>> pageResultResult = studentService.studentList(studentRequest);
        return pageResultResult;
    }

    @PostMapping("/addStudent")
    public Result<Student> addStudent(@RequestBody Student student){
        return studentService.addStudentList(student);
    }

    @PostMapping("/delStudent")
    public Result delStudent(@RequestParam Integer studentId){
        return studentService.delStudent(studentId);
    }

    @PostMapping("/fastUpload")
    public Result fastUpload(@RequestParam("file")MultipartFile multipartFile){
        return studentService.fastUpload(multipartFile);
    }

    @PostMapping("/studentLists")
    public Result<List<Student>> studentLists(){
        return studentService.studentLists();
    }

    @PostMapping("/updStudent")
    public Result<Student> updStudent(@RequestBody Student student){
        return studentService.updStudent(student);
    }

    @PostMapping("/findByStudent")
    public Result<Student> findByStudent(@RequestParam Integer studentId){
        return studentService.findByStudent(studentId);
    }

    @PostMapping("/clazzList")
    public Result<Clazz> clazzList(){
        return studentService.clazzList();
    }

    @PostMapping("/deleteStudent")
    public Result<Student> deleteStudent(@RequestParam Integer studentId){
        return studentService.deleteStudent(studentId);
    }

}
